#include <WinTen.h>
#include <Windows.h>
#include <extend.h>

#define WF_WINNT  0x4000

//----------------------------------------------------------------------------//

CLIPPER CALLWINDOW()
{
   _retnl( CallWindowProc( ( FARPROC ) _parnl( 1 ),
      ( HWND ) _parnl( 2 ), _parni( 3 ), _parni( 4 ), _parnl( 5 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER ISCHILD() // ( hWndParent, hWndCHild ) --> lSuccess
{
   _retl( IsChild( ( HWND ) _parnl( 1 ), ( HWND ) _parnl( 2 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER ISICONIC()
{
   _retl( IsIconic( ( HWND ) _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER ISZOOMED()
{
   _retl( IsZoomed( ( HWND ) _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER ISDEFBUTTO()  // N( hWnd ) --> lDefault
{
   _retl( GetWindowLong( ( HWND ) _parnl( 1 ), GWL_STYLE ) & BS_DEFPUSHBUTTON );
}

//----------------------------------------------------------------------------//

CLIPPER CLOSEWINDO()  // W( hWnd )
{
   CloseWindow( ( HWND ) _parnl( 1 ) );
}

//----------------------------------------------------------------------------//

CLIPPER GETWINDOWL() // ONG( hWnd, nType ) --> nValue
{
   _retnl( GetWindowLong( ( HWND ) _parnl( 1 ), _parni( 2 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER SETWINDOWL() // ONG( hWnd, nIndex, nValue ) --> nOldValue
{
   _retnl( SetWindowLong( ( HWND ) _parnl( 1 ), _parni( 2 ), _parnl( 3 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER FINDWINDOW() // ( cClassName, cTitle ) --> hWnd
{
   _retnl( ( LONG ) FindWindow( IF( ISCHAR( 1 ), _parc( 1 ), 0 ),
                                IF( ISCHAR( 2 ), _parc( 2 ), 0 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER GETCLASSIN() // FO( hInst, cClassName )  --> aInfo or nil
{
   WNDCLASS wndCls;

   if( GetClassInfo( ( HANDLE ) _parnl( 1 ), _parc( 2 ), &wndCls ) )
   {
      _reta( 10 );
      _stornl( ( LONG ) wndCls.style,       -1,  1 );
      _stornl( ( LONG ) wndCls.lpfnWndProc, -1,  2 );
      _storni( wndCls.cbClsExtra,    -1,  3 );
      _storni( wndCls.cbWndExtra,    -1,  4 );
      _stornl( ( LONG ) wndCls.hInstance,     -1,  5 );
      _stornl( ( LONG ) wndCls.hIcon,         -1,  6 );
      _stornl( ( LONG ) wndCls.hCursor,       -1,  7 );
      _stornl( ( LONG ) wndCls.hbrBackground, -1,  8 );
      _storc( ( LPSTR ) wndCls.lpszMenuName,   -1,  9 );
      _storc( ( LPSTR ) wndCls.lpszClassName,  -1, 10 );
   }
   else
      _ret();
}

//----------------------------------------------------------------------------//

CLIPPER ISWINDOW()
{
   _retl( IsWindow( ( HWND ) _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER ISWINDOWVI() // SIBLE( hWnd ) --> <lVisible>
{
   _retl( IsWindowVisible( ( HWND ) _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER GETACTIVEW()  //INDOW() --> hWnd
{
   _retnl( ( LONG ) GetActiveWindow() );
}

//----------------------------------------------------------------------------//

// CLIPPER GETWINFLAG() // S()  --> nFlags
// {
//   _retnl( GetWinFlags() );
// }

//----------------------------------------------------------------------------//

CLIPPER WINDOWFROM() // POINT
{
   POINT pt;

   pt.x = _parni( 1 );
   pt.y = _parni( 2 );

   _retnl( ( LONG ) WindowFromPoint( pt ) );
}

//----------------------------------------------------------------------------//

// CLIPPER ISWINNT()     // Check if WIN NT is running
// {
//   _retl( GetWinFlags() & WF_WINNT );
// }

//----------------------------------------------------------------------------//

BOOL IsWin95( void )
{
   LONG lInfo = GetVersion();

   return LOBYTE( LOWORD( lInfo ) ) > 3 ||
          HIBYTE( LOWORD( lInfo ) ) > 6;
}

//----------------------------------------------------------------------------//

CLIPPER ISWIN95()     // Check if WIN 95 is running
{
   _retl( IsWin95() );
}

//----------------------------------------------------------------------------//

CLIPPER ENABLEWIND() // OW( hWnd, lOnOff ) --> lSuccess
{
   HWND hWnd = ( HWND ) _parnl( 1 );

   if( IsWindow( hWnd ) )
      _retl( EnableWindow( ( HWND ) _parnl( 1 ),       //      HWND
                                    _parl( 2 ) ) );    //      lOnOff
   else
      _retl( FALSE );
}

//----------------------------------------------------------------------------//

CLIPPER ISWINDOWEN() // ABLED( hWnd )  --> lEnabled
{
   _retl( IsWindowEnabled( ( HWND ) _parnl( 1 ) ) );
}

//----------------------------------------------------------------------------//
